/*******************************************************************************
 * Copyright (c) 2013 INTERAMERICAN PROPERTY AND CASUALTY INSURANCE COMPANY S.A. 
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v3
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/copyleft/lesser.html
 * 
 * This library is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 * See the GNU Lesser General Public License for more details.
 ******************************************************************************/
package gr.interamerican.bo2.utils.meta.ext.formatters;

import gr.interamerican.bo2.arch.PersistentObject;
import gr.interamerican.bo2.utils.meta.formatters.Formatter;
import gr.interamerican.bo2.utils.meta.formatters.ObjectFormatter;
import gr.interamerican.bo2.utils.meta.formatters.nr.NullReturningFormatter;

/**
 * This {@link Formatter} will use the string representation of a
 * {@link PersistentObject}'s key as its string representation.
 */
public class PoKeyFormatter
implements Formatter<PersistentObject<?>> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * Formatter.
	 */
	Formatter<Object> kf = new NullReturningFormatter<Object>(ObjectFormatter.<Object>getInstance());


	public String format(PersistentObject<?> t) {
		Object key = t.getKey();		
		return kf.format(key);
	}

}
